#include "system/pluginmanager.h"

namespace dw {
	namespace system {

PluginManager::PluginManager()
{
}

PluginManager::~PluginManager()
{
	/*for (PluginIterator i = _plugins.begin(); i != _plugins.end(); ++i)
	{
		DW_MODULE_HANDLE_TYPE handle = i->second->getHandle();
		i->second->release();
		DW_MODULE_FREE(i->second->getHandle());
	}
	_plugins.clear();*/
}

IPlugin* PluginManager::LoadPlugin(const std::string& filename)
{
	/*typedef Plugin* (*pfn)(const DW_MODULE_HANDLE_TYPE&);
	
	DW_MODULE_HANDLE_TYPE handle;
	pfn createPlugin;
	Plugin* plugin = 0;
	
	handle = DW_MODULE_LOAD(filename.c_str());
	if (handle)
	{
		createPlugin = reinterpret_cast< pfn >(DW_MODULE_FUNCTION_GET(handle, "createPlugin"));
		if (createPlugin)
		{
			plugin = createPlugin(handle);
			_plugins.insert(std::make_pair(filename, plugin));
		}
	}
	return plugin;*/
	return 0;
}

bool PluginManager::FreePlugin(const std::string& modulename)
{
	/*PluginIterator i = _plugins.find(modulename);
	
	if (i != _plugins.end())
	{
		DW_MODULE_HANDLE_TYPE handle = i->second->getHandle();
		i->second->release();
		DW_MODULE_FREE(handle);
		_plugins.erase(i);
		return true;
	}*/
	return false;
}

	} // namespace system
} // namespace dw
